local parent, ns = ...
local psLib = ns.psLib;

psLib.commandOptions = {};
psLib.AddCMDCommand = function(self, commandName, commandFunction)
	if(commandName and commandName ~= "" and commandFunction) then
		commandName = strlower(commandName);
		psLib.commandOptions[commandName] = commandFunction;
	end
end

psLib:AddChatCommand("cmd",function(...)
	local args = { ... };
	for _,value in pairs(args) do
        local commands = { strsplit(" ", value) };
        if(#commands == 1 and commands[1] == "") then
            print("Available option commands:");
			for key, command in pairs(psLib.commandOptions) do
				print("- " .. key);
			end
        else
            for _,command in pairs(commands) do
                local option, optionValue = strsplit(":", command);
				option      = strlower(option or "");
				optionValue = strlower(optionValue or "");
				if(psLib.commandOptions[option]) then psLib.commandOptions[option](optionValue); 
				elseif(option ~= "") then print(option .. " is unknown"); end
            end
        end
    end
end
);